(use-package auto-complete
  :ensure
  :bind (:map global-map
              ("<C-return>" . ac-complete)
              ("<M-return>" . auto-complete)))
(require 'auto-complete)
(require 'auto-complete-config)
(require 'pos-tip)
(ac-config-default)
(global-auto-complete-mode t)
(setq ac-quick-help-prefer-pos-tip t)
(setq ac-auto-start t)
(setq ac-quick-help-delay 0.5)
(setq ac-fuzzy-enable t)

(defun ac-common-setup ()
  (add-to-list 'ac-sources
    '(ac-source-filename
      ac-source-functions
      ac-source-yasnippet
      ac-source-variables
      ac-source-symbols
      ac-source-features
      ac-source-abbrev
      ac-source-words-in-buffers
      ac-source-words-in-same-mode-buffers
      ac-source-words-in-all-buffers
      ac-source-dictionary
      ac-source-gtags
      ac-source-imenu
      ac-source-semantic
      ac-source-c-headers
      ac-source-c-header-symbols))
  (setq ac-clang-flags
        (mapcar (lambda (item)(concat "-I" item))
                (split-string
                 "
 /usr/include/c++/7
 /usr/include/x86_64-linux-gnu/c++/7
 /usr/include/c++/7/backward
 /usr/lib/gcc/x86_64-linux-gnu/7/include
 /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
 /usr/include/c++/8
 /usr/include/x86_64-linux-gnu/c++/8
 /usr/include/c++/8/backward
 /usr/lib/gcc/x86_64-linux-gnu/8/include
 /usr/lib/gcc/x86_64-linux-gnu/8/include-fixed
 /usr/include/c++/9
 /usr/include/x86_64-linux-gnu/c++/9
 /usr/include/c++/9/backward
 /usr/lib/gcc/x86_64-linux-gnu/9/include
 /usr/lib/gcc/x86_64-linux-gnu/9/include-fixed
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include")))
  )
(add-hook 'auto-complete-mode-hook 'ac-common-setup)
(provide 'init_auto-complete)
